package com.ica.android.ui.command;

import com.ica.R;
import com.ica.model.command.ComposedCommand;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;

public class NewCommandActivity extends CommandActivity {
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        init(R.layout.new_command);
	}
	
	@Override
	protected OnClickListener onClickSave() {	
		return new OnClickListener() {			
			public void onClick(View arg0) {
				if (etName.getText().toString().equals(""))
					Toast.makeText(NewCommandActivity.this, "The Command's name is required", Toast.LENGTH_SHORT).show();
				else {
					command = new ComposedCommand(etName.getText().toString());
					getCommandDefined(command);
					commandFacade.addElement(command.getId(), command);
					setResult(RESULT_OK,null);
					finish();
				}
			}
		};
	}

}
